package com.bwie.controller;

import com.bwie.pojo.Result;
import com.bwie.pojo.dto.VisitDto;
import com.bwie.pojo.po.RegistrationPo;
import com.bwie.pojo.vo.RegistrationVo;
import com.bwie.pojo.vo.VisitVo;
import com.bwie.service.RegistrationService;
import com.bwie.service.VisitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @ 就诊
 * @descriptions: VisitController
 * @author: LiYang
 * @date: 2025/3/17 0:08
 * @version: 1.0
 */
@Controller
@RequestMapping("visit")
public class VisitController {
    @Autowired
    private VisitService visitService;
    @Autowired
    private RegistrationService registrationService;

    /**
     * 去就诊列表
     * @return
     */
    @RequestMapping("toList")
    public String toList(){
        return "visit/list";
    }

    /**
     * 就诊方法
     * @param registrationVo
     * @return
     */
    @RequestMapping("updAdd")
    @ResponseBody
    public Result updAdd(@RequestBody RegistrationVo registrationVo){
        return visitService.updAdd(registrationVo);
    }

    /**
     * 就诊列表
     * @param visitDto
     * @return
     */
    @RequestMapping("getList")
    @ResponseBody
    public Result getList(VisitDto visitDto){
        return visitService.getList(visitDto);
    }

    /**
     * 去退号页面
     * @param registrationId
     * @param model
     * @return
     */
    @RequestMapping("toSet")
    public String toSet(Integer registrationId, Model model){
        RegistrationVo registrationVo=registrationService.selectId(registrationId);
        model.addAttribute("registrationVo",registrationVo);
        return "registration/toSet";
    }
    /**
     * 去退号页面
     * @param visitId
     * @param model
     * @return
     */
    @RequestMapping("set")
    public String set(Integer visitId, Model model){
       VisitVo visitVo= visitService.selectId(visitId);
        model.addAttribute("visitVo",visitVo);
        return "visit/set";
    }

    /**
     * 退号
     * @param registrationPo
     * @return
     */
    @ResponseBody
    @RequestMapping("toOut")
    public Result toOut(@RequestBody RegistrationPo registrationPo){
        return registrationService.toOut(registrationPo);
    }
}
